<?php
class MHDEV_View_Helper_GetDirectories extends Zend_View_Helper_Abstract 
{
	public function GetDirectories($path, $i=0)
	{
		$url_helper = new Zend_View_Helper_Url();
		$content	= '';
		if(is_dir($path))
		{
			$handle 		= opendir($path);
			$files 			= array();
			$directories	= array();
			
			while($file = readdir($handle))
			{
				If(is_dir($path.$file))
				{
					if($file != '.' && $file != '..' && $file != '.thumbs')
					{
						$padding = $i*10;
						$content .= '<li style="margin-left:' . $padding . 'px;"><a href="';
						$content .= $url_helper->url(
							array(
								'controller' => 'filemanager',  
								'dir' => urlencode($path.$file)
							),'default',true
						);
						$content .= '">';
						$content .= $file;
						$content .= '</a></li>';
						if($this->GetDirectories($path.$file.'/',$i) != '')
						{
							$i++;
							$content .= $this->GetDirectories($path.$file.'/',$i);
							$i=0;
						}
					}
				}
			}
			closedir($handle);
		}
		return $content;
	}
}